/////////
// Replication syntax for obervational analyses of the paper 
// Vierus & Ziller (2025) - Political support in times of progressive policy change and radical-right populist party success
///////// 

	version 17.0
	set more off
	clear all 
	
//intalling ados
local adolist fre markout coefplot asdoc estout rev marhis resize

foreach ado in `adolist' {
    cap which `ado'
    if _rc != 0 {
        di "`ado' is not installed. Installing now..."
        ssc install `ado'
    }
    else {
        di "`ado' is already installed."
		}
}	
			
//Set up working directry and load dataset
********************************************************************************	
cd "WORKING DIRECTORY" 
use "VZ_observational_data.dta", clear

//Creating country sample
keep if inlist(cntry_2,"BE","CZ","DE","DK","EE") | inlist(cntry_2,"FI","FR","GB","NL","NO","SE")

//Creating individual sample
mark nonmiss
markout nonmiss trstprl  trstplt trstprt stfgov poltrust_3  stfdem  lrscale land2 income occupation sex age eduyrs   rpopvote_parlgov  reg_support gdp unemploy ausl_share

fre nonmiss
drop if nonmiss != 1	
	
encode cntry_2, gen(c)
tab cntry_2 year
egen cyear=group(cntry_2 year)


//Creating overall progressiveness index over all three policy fields
**************************************************	
foreach var of varlist stfdem lrscale income age eduyrs gdp unemploy ausl_share mipex1 climate_index ggr rpopvote_parlgov oecd_famben stfgov poltrust_3 lpopvote_v2{
	egen z_`var' = std(`var')
}
	
alpha z_mipex1 z_climate_index z_ggr, item gen(super_prog)	//0,70


//Standardizing the variables
foreach var of varlist  lrscale land2 income occupation sex age eduyrs ausl_share rpopvote_parlgov super_prog gdp unemploy mipex1 climate_index ggr lpopvote_v2{
	sum `var' 
	gen sx`var'=(`var'-r(min)) 
	sum sx`var' 
	gen std2`var'=sx`var'/r(max) 
}

//Creating temporary clones of variables for analyses
clonevar prog_bin_int=z_rpopvote_parlgov
clonevar super_prog_int=super_prog
clonevar z_rpopvote_parlgov_int = z_rpopvote_parlgov

//Saving	
compress
save "VZ_observational_data_sample.dta", replace


///////////////////////////////////////////////////////////////////////
		//Analyses
///////////////////////////////////////////////////////////////////////

**# Figure 1 in observational design
***************************************
use "VZ_observational_data_sample", clear

estimates clear  
foreach var of varlist z_stfgov z_poltrust_3 {
	use "VZ_observational_data_sample.dta", clear
	rename super_prog prog
	qui mixed   `var'  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs  z_ausl_share c.z_rpopvote_parlgov c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
	est sto alle_`var'		

	use "VZ_observational_data_sample.dta", clear
	rename super_prog_int prog_int
	qui mixed   `var'  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs  z_ausl_share c.z_rpopvote_parlgov_int##c.prog_int z_gdp z_unemploy   i.year  i.c ||cyear: , robust
	est sto alleint_`var'		
}

//Creating figure
coefplot alle_* alleint_* ,  bylabel(All topics)  xline(0) mcolor(navy) ciopts(color(navy))  ///
order(prog z_rpopvote_parlgov c.z_rpopvote_parlgov_int#c.prog_int) keep(*rpopvote_parlgov  *prog c.z_rpopvote_parlgov_int#c.prog_int) drop(*_parlgov#c*) xline(0) legend(pos(6) cols(2))  byopts(cols(5) /*legend(off)*/) ///
p1(label(Satisfaction with government)) p2(label(Trust in pol. institutions)) p3(label(Satisfaction with democracy)) ///
coeflabels(c.z_rpopvote_parlgov_int#c.prog_int= `" "Progressive policy" "× voteshare RRPP" "' prog = "Progressive policy" z_rpopvote_parlgov = "Voteshare RRPP") nolabel scheme(plotplain) graphregion(col(white)) bgcol(white) xlabel(-.6(.2).2) xscale(range(-.6(.2).2)) name(maineffects, replace) nokey
resize maineffects, xsize(10cm) ysize(9cm)		

graph export "fig1.png", replace	

**# Figure 2 in observational design - Conditional Plots with standardized effects +  Satisfaction with government 
***************************************

//Base
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy    i.year  i.c ||cyear: , robust
est sto base

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c ||cyear: , robust
est sto base_int

//income
use "VZ_observational_data_sample", clear
fre income
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if hinctnta <5 ||cyear: , robust
est sto income

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if hinctnta <5 ||cyear: , robust
est sto income_int

//subj Income
use "VZ_observational_data_sample", clear
fre income
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if income <3 ||cyear: , robust
est sto subjincome

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if income <3 ||cyear: , robust
est sto subbjincome_int

//female
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy    i.year  i.c if sex == 0 ||cyear: , robust
est sto female

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if sex == 0 ||cyear: , robust
est sto female_int

//educ
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if edu_isced < 4||cyear: , robust
est sto educ

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if edu_isced < 4 ||cyear: , robust
est sto educ_int

//lrscale
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if lrscale > 5 ||cyear: , robust
est sto lrscale

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy      i.year  i.c if lrscale > 5 ||cyear: , robust
est sto lrscale_int

//tradition
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if tradition>4 ||cyear: , robust
est sto tradition

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if tradition>4 ||cyear: , robust
est sto tradition_int

//age
use "VZ_observational_data_sample", clear
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if age>51 ||cyear: , robust
est sto age

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy    i.year  i.c if  age>51  ||cyear: , robust
est sto age_int

//countryside 
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if land2 == 1  ||cyear: , robust
est sto land2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy   i.year  i.c if  land2 == 1  ||cyear: , robust 
est sto land2_int

coefplot educ educ_int base base_int,  bylabel(1 Low education) xline(0) mcolor(navy) ciopts(color(navy))  ///
|| income income_int base base_int, bylabel(2 Low coping income)  ///		
|| subjincome subbjincome_int base base_int, bylabel(3 Low income)  ///		
|| female female_int base base_int, bylabel(4 Male) ///
|| age age_int base base_int, bylabel(5 Age (> median (51))) ///
|| lrscale lrscale_int base base_int, bylabel(6 Ideology - right)  ///
|| tradition tradition_int base base_int, bylabel(7 Traditionalism - high)  ///
|| land2 land2_int base base_int, bylabel(8 Living in rural area)  ///
order(super_prog rpopvote_parlgov) keep(*super_prog* *rpopvote_parlgov c.pop#c.prog) xline(0) 	xlabel(-.6(.2).2) xscale(range(-.65(.2).2))  headings(2.progressive=`" "{bf:Policy progressiveness}" "(ref. no progressiveness)" "' 2.populism=`" "{bf:Populism}" "(ref. no populism mentioned)" "' 1.prog_bin#1.pop_bin = "{bf:Interaction}")    legend(position(6) cols(2)) byopts(cols(4) /*compact*/) name(conditional_v2, replace)	coeflabels(z_rpopvote_parlgov="Voteshare RRPP" super_prog = "Progressive policy" c.pop#c.prog=`"  "Progressive policy" "× voteshare RRPP" "',labsize(small)) subtitle(, size(small))  nokey
	
graph export "Fig2.png", replace
	
	
**************************************************	
**************************************************
//Appendix 
**************************************************	
**************************************************	
use "VZ_observational_data_sample", clear

**# A2 - Sample Characteristics
***************************************
tab occupation, gen(occupation_)
asdoc tabstat stfgov poltrust_3 lrscale land2 income occupation_* sex age migr eduyrs ausl_share  rpopvote_parlgov  gdp unemploy ggr mipex1 climate_index super_prog oecd_famben   ///
, statistics(mean sd min max) fs(8) replace dec(2) save(A2) 				

//Getting the overall N
 sum stfgov poltrust_3 stfdem lrscale land2 income occupation_* sex age eduyrs ausl_share  rpopvote_parlgov  gdp unemploy ggr mipex1 climate_index super_prog oecd_famben	

**# A3 - Correlation matrix
***************************************
asdoc cor stfgov poltrust_3 lrscale land2 income occupation sex age migr  eduyrs ausl_share  rpopvote_parlgov  gdp unemploy ggr mipex1 climate_index super_prog oecd_famben , fs(8) replace dec(2) save(A3) 

**# A4 - Full models tables without interactions
***************************************
estimates clear		
mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r1
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r2

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.z_ggr z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r3
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.z_ggr z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r4

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.z_mipex1 z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r5
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.z_mipex1 z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r6

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.z_climate_index z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r7
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.z_climate_index z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r8

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.z_oecd_famben z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r9
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age  migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.z_oecd_famben z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto r10

esttab r1 r2  r3 r4  r5 r6  using "A4_part1.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@)) 
esttab r7 r8  r9 r10   using "A4_part2.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@)) 	


**# A5 Full models tables with interactions	
***************************************
estimates clear
mixed   z_stfgov z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.super_prog z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t1
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.super_prog z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t2

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_ggr z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t3
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_ggr z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t4

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_mipex1 z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t5
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_mipex1 z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t6

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_climate_index z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t7
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_climate_index z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t8

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_oecd_famben z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t9
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_oecd_famben z_gdp z_unemploy  i.year  i.c ||cyear:  , robust
est sto t10

esttab t1 t2  t3 t4  t5 t6  using "A5_part1.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@)) 

esttab t7 t8  t9 t10   using "A5_part2.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@)) 

	
**# A6 Leftpop for alle policies seperatly
***************************************
estimates clear  
foreach var of varlist z_stfgov z_poltrust_3{
use "VZ_observational_data_sample", clear
rename z_ggr prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2 c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto gender_`var'

use "VZ_observational_data_sample", clear
rename z_mipex1 prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2 c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto integr_`var'

use "VZ_observational_data_sample", clear
rename z_climate_index prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2 c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto climate_`var'	

use "VZ_observational_data_sample", clear
rename super_prog prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2 c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto alle_`var'		

use "VZ_observational_data_sample", clear
rename z_oecd_famben prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2 c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto zoecdfamben_`var'	

use "VZ_observational_data_sample", clear
rename z_ggr prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto genderint_`var'

use "VZ_observational_data_sample", clear
rename z_mipex1 prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto integrint_`var'

use "VZ_observational_data_sample", clear
rename z_climate_index prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto climateint_`var'	

use "VZ_observational_data_sample", clear
rename super_prog prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto alleint_`var'		

use "VZ_observational_data_sample", clear
rename z_oecd_famben prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_lpopvote_v2##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto zoecdfambenint_`var'

}

//Main effects
coefplot alle_* ,  bylabel(Progressive policies)  xline(0) mcolor(navy) ciopts(color(navy))  ///
	|| gender_* , bylabel(Gender equity) ///			
	|| integr_*  , bylabel(Integration)  ///
	|| climate_* , bylabel(Climate change) ///
	|| zoecdfamben_*, bylabel(Family) ///
	order(*prog* *z_lpopvote_v2*) keep(*z_lpopvote_v2*  *prog*) drop(*z_lpopvote_v2#c*) xline(0) legend(pos(9) cols(3))   byopts(cols(5) ) ///
	p1(label(Satisfaction with government)) p2(label(Trust in pol. institutions)) ///
	coeflabels(c.z_rpopvote_parlgov#c.prog= `" "Progressive policy" "× populism policy position" "' prog = "Progressive policy" z_lpopvote_v2 = "Voteshare LWP") nolabel scheme(plotplain) graphregion(col(white)) bgcol(white) xlabel(-1(.5)1) xscale(range(-1(.5)1)) name(maineffectslpop, replace) 
		
resize maineffectslpop, xsize(16cm) ysize(8cm)		
graph export "A6_main.png", replace

//Interaction
coefplot  alleint_*,  bylabel(Progressive policies)  xline(0)  mcolor(maroon) ciopts(color(maroon))  ///
	||  genderint_*, bylabel(Gender equity) ///
	||  integrint_* , bylabel(Integration)  ///
	||  climateint_*, bylabel(Climate change) ///
	|| zoecdfambenint_*, bylabel(Family) ///
	 keep( *z_lpopvote_v2#c* ) xline(0)  legend(pos(9) cols(3)) byopts(cols(5) /*legend(off)*/) ///
	p1(label(Satisfaction with government)) p2(label(Trust in pol. institutions)) ///
	coeflabels(c.z_lpopvote_v2#c.prog= `" "Voteshare LWP" "× progressive policy" "' prog = "Progressive policy" z_lpopvote_v2 = "Voteshare LWP") nolabel scheme(plotplain) graphregion(col(white)) bgcol(white) xlabel(-1(.5)1) xscale(range(-1(.5)1)) name(interactioneffectslpop, replace)

resize interactioneffectslpop, xsize(16cm) ysize(6cm)
graph export "A6_interaction.png", replace
	
	
**# A7  Rightpop seperatly for all policies
***************************************

estimates clear  
foreach var of varlist z_stfgov z_poltrust_3{
use "VZ_observational_data_sample", clear
rename z_ggr prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto gender_`var'

use "VZ_observational_data_sample", clear
rename z_mipex1 prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto integr_`var'

use "VZ_observational_data_sample", clear
rename z_climate_index prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto climate_`var'	

use "VZ_observational_data_sample", clear
rename z_oecd_famben prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto zoecdfamben_`var'	

use "VZ_observational_data_sample", clear
rename super_prog prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto alle_`var'			


use "VZ_observational_data_sample", clear
rename z_ggr prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto genderint_`var'

use "VZ_observational_data_sample", clear
rename z_mipex1 prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto integrint_`var'

use "VZ_observational_data_sample", clear
rename z_climate_index prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto climateint_`var'	

use "VZ_observational_data_sample", clear
rename z_oecd_famben prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto zoecdfambenint_`var'

use "VZ_observational_data_sample", clear
rename super_prog prog
qui mixed   `var'  z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
est sto alleint_`var'		

}

coefplot  alle_* , bylabel(Progressive policies)   xline(0) mcolor(navy) ciopts(color(navy))  ///
	|| gender_* , bylabel(Gender Equity) ///
	|| integr_*  , bylabel(Integration)  ///
	|| climate_* , bylabel(Climate change) ///
	|| zoecdfamben_*, bylabel(Family) ///
	order(*prog* *z_rpopvote_parlgov*) keep(*z_rpopvote_parlgov*  *prog*) drop(*z_rpopvote_parlgov#c*) xline(0) legend(pos(9) cols(3))   byopts(cols(5) ) ///
	p1(label(Satisfaction with government)) p2(label(Trust in pol. institutions)) ///
	coeflabels(c.z_rpopvote_parlgov#c.prog= `" "Progressive policy" "× voteshare RRPP" "' prog = "Progressive policy" z_rpopvote_parlgov = "Voteshare RRPP") nolabel scheme(plotplain) graphregion(col(white)) bgcol(white) xlabel(-.5(.2).5) xscale(range(-.5(.2).5)) name(maineffectslpop, replace) 

resize maineffectslpop, xsize(16cm) ysize(8cm)		
graph export "A7_main.png", replace


coefplot alleint_*, bylabel(Progressive policies) xline(0)  mcolor(maroon) ciopts(color(maroon))  ///
	|| genderint_* ,bylabel(Gender equity) ///
	||  integrint_* , bylabel(Integration)  ///
	||  climateint_*, bylabel(Climate change) ///
	|| zoecdfambenint_*, bylabel(Family) ///
	 keep( *z_rpopvote_parlgov#c* ) xline(0)  legend(pos(9) cols(3)) byopts(cols(5) /*legend(off)*/) ///
	p1(label(Satisfaction with government)) p2(label(Trust in pol. institutions)) ///
	coeflabels(c.z_rpopvote_parlgov#c.prog= `" "Voteshare RRPP" "× progressive policy" "' prog = "Progressive policy" z_rpopvote_parlgov = "Voteshare RRPP") nolabel scheme(plotplain) graphregion(col(white)) bgcol(white) xlabel(-.5(.2).5) xscale(range(-.5(.2).5)) name(interactioneffectslpop, replace)

resize interactioneffectslpop, xsize(16cm) ysize(6cm)
graph export "A7_interaction.png", replace
	
	
**# A8 Coefplot for model including all interactions
***************************************
use "VZ_observational_data_sample", clear
	
mixed  z_stfgov   z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_ggr c.z_rpopvote_parlgov##c.z_mipex1  c.z_rpopvote_parlgov##c.z_climate_index  c.z_rpopvote_parlgov##c.z_oecd_famben z_gdp z_unemploy  i.year  i.c ||cyear:  , vce(robust)
est sto robust_1

mixed  z_poltrust_3   z_lrscale land2 z_income i.occupation sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.z_ggr c.z_rpopvote_parlgov##c.z_mipex1  c.z_rpopvote_parlgov##c.z_climate_index  c.z_rpopvote_parlgov##c.z_oecd_famben z_gdp z_unemploy  i.year  i.c ||cyear:  , vce(robust)
est sto robust_2

coefplot  robust_*,  xline(0)  mcolor(maroon) ciopts(color(maroon))  ///	
	 keep( *_parlgov#c* ) xline(0)   ///
	p1(label(Satisfaction with government)) p2(label(Trust in pol. institutions)) ///
	nolabel scheme(plotplain) graphregion(col(white)) bgcol(white) /*xlabel(-1(.5)1) xscale(range(-1(.5)1))*/ name(fig_a1, replace)  ///
	coeflabels(c.z_rpopvote_parlgov#c.z_ggr= `" "Voteshare RRPP" "× progressive gender policy" "' ///
		c.z_rpopvote_parlgov#c.z_mipex1= `" "Voteshare RRPP" "× progressive integration policy" "' ///
		c.z_rpopvote_parlgov#c.z_climate_index= `" "Voteshare RRPP" "× progressive climate policy" "' ///
		c.z_rpopvote_parlgov#c.z_oecd_famben= `" "Voteshare RRPP" "× progressive family policy" "') 
				
graph export "A8.png", replace				

**# A9 Marginal effect plot of main effect & Point estimates for the footnote in the text
***************************************	
use "VZ_observational_data_sample", clear

mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age i.migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.super_prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
marhis z_rpopvote_parlgov, mar(super_prog)

//point estimates for the text: 
mixed   z_stfgov  z_lrscale land2 z_income i.occupation sex z_age i.migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.super_prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
	sum rpopvote_parlgov // --> 6,1% sind eine SD
	//+1 SD	
	//-1 SD

margins, dydx(super_prog) at(z_rpopvote_parlgov == -1)	// -.006 se .11 --> in niedrigen populistischen kontexten
margins, dydx(super_prog) at(z_rpopvote_parlgov == +1)	// -.261 se .10 --> in hohen populistischen Kontexten

//poltrust
mixed   z_poltrust_3  z_lrscale land2 z_income i.occupation sex z_age  i.migr z_eduyrs z_ausl_share c.z_rpopvote_parlgov##c.super_prog z_gdp z_unemploy   i.year  i.c ||cyear: , robust
margins, dydx(super_prog) at(z_rpopvote_parlgov == -1)	// -.066 se .035 --> in niedrigen populistischen kontexten
margins, dydx(super_prog) at(z_rpopvote_parlgov == +1)	// -.077 se .037 --> in hohen populistischen Kontexten
	
graph export "A9.png", replace					
	
**# A10 Subgroup analyses with DV: Trust in Government
***************************************	

//Base
use "VZ_observational_data_sample", clear
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy    i.year  i.c ||cyear: , robust
est sto base

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c ||cyear: , robust
est sto base_int

//income
use "VZ_observational_data_sample", clear
fre income
mixed z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if hinctnta <5 ||cyear: , robust
est sto income

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if hinctnta <5 ||cyear: , robust
est sto income_int

//subj Income
use "VZ_observational_data_sample", clear
fre income
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if income <3 ||cyear: , robust
est sto subjincome

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if income <3 ||cyear: , robust
est sto subbjincome_int

//female
use "VZ_observational_data_sample", clear
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy    i.year  i.c if sex == 0 ||cyear: , robust
est sto female

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if sex == 0 ||cyear: , robust
est sto female_int

//educ
use "VZ_observational_data_sample", clear
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if edu_isced < 4||cyear: , robust
est sto educ

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if edu_isced < 4 ||cyear: , robust
est sto educ_int

//lrscale
use "VZ_observational_data_sample", clear
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if lrscale > 5 ||cyear: , robust
est sto lrscale

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy      i.year  i.c if lrscale > 5 ||cyear: , robust
est sto lrscale_int

//tradition
use "VZ_observational_data_sample", clear
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if tradition>4 ||cyear: , robust
est sto tradition

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if tradition>4 ||cyear: , robust
est sto tradition_int

//age
use "VZ_observational_data_sample", clear
mixed z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if age>51 ||cyear: , robust
est sto age

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy    i.year  i.c if  age>51  ||cyear: , robust
est sto age_int

//countryside 
use "VZ_observational_data_sample", clear
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if land2 == 1  ||cyear: , robust
est sto land2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_poltrust_3  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy   i.year  i.c if  land2 == 1  ||cyear: , robust 
est sto land2_int

coefplot educ educ_int base base_int,  bylabel(1 Low education) xline(0) mcolor(navy) ciopts(color(navy))  ///
|| income income_int base base_int, bylabel(2 Low coping income)  ///		
|| subjincome subbjincome_int base base_int, bylabel(3 Low income)  ///		
|| female female_int base base_int, bylabel(4 Male) ///
|| age age_int base base_int, bylabel(5 Age (> median (51))) ///
|| lrscale lrscale_int base base_int, bylabel(6 Ideology - right)  ///
|| tradition tradition_int base base_int, bylabel(7 Traditionalism - high)  ///
|| land2 land2_int base base_int, bylabel(8 Living in rural area)  ///
order(super_prog rpopvote_parlgov) keep(*super_prog* *rpopvote_parlgov c.pop#c.prog) xline(0) 	/*xscale(range(-0.5(0.2)0.5)) xlabel(-0.5(0.2)0.5)*/  headings(2.progressive=`" "{bf:Policy progressiveness}" "(ref. no progressiveness)" "' 2.populism=`" "{bf:Populism}" "(ref. no populism mentioned)" "' 1.prog_bin#1.pop_bin = "{bf:Interaction}")    legend(position(6) cols(2)) byopts(cols(4) /*compact*/) name(conditional_v2, replace)	coeflabels(z_rpopvote_parlgov="Voteshare RRPP" super_prog = "Progressive policy" c.pop#c.prog=`" "Progressive policy" "× voteshare RRPP"  "',labsize(small)) subtitle(, size(small))

resize conditional_v2, xsize(18cm) ysize(11cm)		
graph export "A10.png", replace

**# A11 Subgroup analyses with DV: Satisfactin with contrasting groups
***************************************	

//income
use "VZ_observational_data_sample", clear
fre income
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if inlist(hinctnta,5,6,7,8,9,10) ||cyear: , robust
est sto income2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if inlist(hinctnta,5,6,7,8,9,10) ||cyear: , robust
est sto income_int2

//subj Income
use "VZ_observational_data_sample", clear
fre income
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if income >= 3 ||cyear: , robust
est sto subjincome2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if income >= 3 ||cyear: , robust
est sto subbjincome_int2

//female
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy    i.year  i.c if sex == 1 ||cyear: , robust
est sto female2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if sex == 1 ||cyear: , robust
est sto female_int2

//educ
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if inlist(edu_isced,4,5,6,7) ||cyear: , robust
est sto educ2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if inlist(edu_isced,4,5,6,7) ||cyear: , robust
est sto educ_int2

//lrscale
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if lrscale  <=5 ||cyear: , robust
est sto lrscale2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy      i.year  i.c if lrscale <=5 ||cyear: , robust
est sto lrscale_int2

//tradition
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy  i.year  i.c if tradition<=4 ||cyear: , robust
est sto tradition2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy     i.year  i.c if tradition<=4 ||cyear: , robust
est sto tradition_int2

//age
use "VZ_observational_data_sample", clear
mixed z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if age<=51  ||cyear: , robust
est sto age2

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy    i.year  i.c if  age<=51  ||cyear: , robust
est sto age_int2

//countryside 
use "VZ_observational_data_sample", clear
mixed  z_stfgov  z_lrscale land2 z_income i.occupation i.migr  sex z_age z_eduyrs z_ausl_share c.z_rpopvote_parlgov c.super_prog z_gdp z_unemploy   i.year  i.c if land2 == 0  ||cyear: , robust
est sto land22

use "VZ_observational_data_sample", clear
rename z_rpopvote_parlgov pop
rename super_prog prog
mixed  z_stfgov  z_lrscale land2 z_income i.occupation  i.migr  sex z_age z_eduyrs z_ausl_share c.pop##c.prog z_gdp z_unemploy   i.year  i.c if  land2 == 0  ||cyear: , robust 
est sto land2_int2

coefplot educ educ_int educ2 educ_int2 ,  bylabel(1 Low education) xline(0) mcolor(navy) ciopts(color(navy))  ///
|| subjincome subbjincome_int subjincome2 subbjincome_int2, bylabel(2 Low income)  ///	
|| income income_int income2 income_int2, bylabel(3 Low coping income)  ///				
|| female female_int female2 female_int2, bylabel(4 Male) ///
|| age age_int  age2 age_int2, bylabel(5 Age (> median (51))) ///
|| lrscale lrscale_int lrscale2 lrscale_int2, bylabel(6 Ideology - right)  ///
|| tradition tradition_int tradition2 tradition_int2, bylabel(7 Traditionalism - high)  ///
|| land2 land2_int land22 land2_int2, bylabel(8 Living in rural area)  ///
order(super_prog rpopvote_parlgov) keep(*super_prog* *rpopvote_parlgov c.pop#c.prog) xline(0) 	/*xscale(range(-0.5(0.2)0.5)) xlabel(-0.5(0.2)0.5)*/  headings(2.progressive=`" "{bf:Policy progressiveness}" "(ref. no progressiveness)" "' 2.populism=`" "{bf:Populism}" "(ref. no populism mentioned)" "' 1.prog_bin#1.pop_bin = "{bf:Interaction}")    legend(position(6) cols(2)) byopts(cols(4) /*compact*/) name(conditional_v2, replace)	coeflabels(z_rpopvote_parlgov="Voteshare RRPP" super_prog = "Progressive policy" c.pop#c.prog=`" "Progressive policy" "× voteshare RRPP" "',labsize(small)) subtitle(, size(small))

resize conditional_v2, xsize(18cm) ysize(11cm)		
graph export "A11.png", replace	
	
**# A12 Moderationanalyses using subgroups 
***************************************	
use "VZ_observational_data_sample", clear

//creating helping variables
gen rural = . 
		replace rural = 1 if land2 == 1 & land2!= .
		replace rural = 0 if land2 != 1 & land2!= .
	
rename z_rpopvote_parlgov pop
rename super_prog prog	

//DV: Satisfaction with democracy
//Metric vars	
foreach var of varlist 	age hinctnta tradition lrscale income edu_isced {
	rename `var' moderator

	mixed z_stfgov c.prog##c.moderator  i.year  i.c   ||cyear: ,  robust
	est sto stf1_`var'

	mixed z_stfgov c.pop##c.moderator i.year  i.c   ||cyear: ,  robust
	est sto stf2_`var'
		
	mixed z_stfgov c.prog##c.pop##c.moderator i.year  i.c   ||cyear: ,  robust
	est sto stf3_`var'
	
	rename moderator `var'	
}

//Dummy vars
foreach var of varlist sex rural {
	rename `var' moderator

	mixed z_stfgov c.prog##i.moderator  i.year  i.c   ||cyear: ,  robust
	est sto stf1_`var'

	mixed z_stfgov c.pop##i.moderator i.year  i.c   ||cyear: ,  robust
	est sto stf2_`var'
		
	mixed z_stfgov c.prog##c.pop##i.moderator i.year  i.c   ||cyear: ,  robust
	est sto stf3_`var'
	
	rename moderator `var'		
}
	
	esttab stf1_edu_isced stf2_edu_isced stf3_edu_isced ///
		stf1_hinctnta stf2_hinctnta stf3_hinctnta /// 
		stf1_income stf2_income stf3_income /// 
	using "A12_part1.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@)) keep(c.pop#c.moderator c.prog#c.moderator c.prog#c.pop#c.moderator)
	
	esttab	stf1_age stf2_age stf3_age  /// 
		stf1_lrscale stf2_lrscale stf3_lrscale  /// 
		stf1_tradition stf2_tradition stf3_tradition /// 
			using "A12_part2.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@))keep(c.pop#c.moderator c.prog#c.moderator c.prog#c.pop#c.moderator)
			
	esttab	stf1_rural stf2_rural stf3_rural  /// 	
		stf1_sex stf2_sex stf3_sex /// 		
			using "A12_part3.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@))keep(1.moderator#c.prog 1.moderator#c.pop 1.moderator#c.prog#c.pop)
		
		
//DV: Political trust
//metric vars
foreach var of varlist 	age hinctnta tradition lrscale income edu_isced {
	rename `var' moderator

	mixed z_poltrust_3 c.prog##c.moderator  i.year  i.c   ||cyear: ,  robust
	est sto trust1_`var'

	mixed z_poltrust_3 c.pop##c.moderator i.year  i.c   ||cyear: ,  robust
	est sto trust2_`var'
		
	mixed z_poltrust_3 c.prog##c.pop##c.moderator i.year  i.c   ||cyear: ,  robust
	est sto trust3_`var'
	
	rename moderator `var'
			
}

//dummy vars
foreach var of varlist sex rural {
	rename `var' moderator

	mixed z_poltrust_3 c.prog##i.moderator  i.year  i.c   ||cyear: ,  robust
	est sto trust1_`var'

	mixed z_poltrust_3 c.pop##i.moderator i.year  i.c   ||cyear: ,  robust
	est sto trust2_`var'
		
	mixed z_poltrust_3 c.prog##c.pop##i.moderator i.year  i.c   ||cyear: ,  robust
	est sto trust3_`var'
	
	rename moderator `var'
			
}

esttab trust1_edu_isced trust2_edu_isced trust3_edu_isced ///
trust1_hinctnta trust2_hinctnta trust3_hinctnta /// 
trust1_income trust2_income trust3_income /// 
using "A12_part4.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@)) keep(c.pop#c.moderator c.prog#c.moderator c.prog#c.pop#c.moderator)

esttab	trust1_age trust2_age trust3_age  /// 
trust1_lrscale trust2_lrscale trust3_lrscale  /// 
trust1_tradition trust2_tradition trust3_tradition /// 
	using "A12_part5.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@))keep(c.pop#c.moderator c.prog#c.moderator c.prog#c.pop#c.moderator)
	
esttab	trust1_rural trust2_rural trust3_rural  /// 	
trust1_sex stf2_sex trust3_sex /// 		
	using "A12_part6.rtf" , label b(%8.3f)  replace nogap onecell	 transform(ln*: exp(2*@) 2*exp(2*@))keep(1.moderator#c.prog 1.moderator#c.pop 1.moderator#c.prog#c.pop)
	
		

ex
		
		
		